import _axios from 'axios'

const axios = _axios.create({
    baseURL: ' https://l94wc2001h.execute-api.ap-southeast-2.amazonaws.com',
})

axios.interceptors.response.use(
    response => {
        return Promise.resolve(response.data)
    },
    error => {
        // console.error(error)
        // console.error(JSON.stringify(error)); 
        let text = ''
        switch(error.response.status) {
            case 404:
                text = error.response.status === 404            
                    ? '404'            
                    : '网络异常，请重试';  
                    alert(text)
                return Promise.reject(error.response)
            case 400:
                text = 'err 400'
                alert(text)
                return Promise.reject(error.response)

            default:
                return Promise.reject(error.response)
        }
        
    }
)

export default axios